import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_html/style.dart';
import 'package:provider/provider.dart';
import 'dart:convert';
import 'package:text_world/global.dart';
import 'package:text_world/main_manager.dart';
import 'package:text_world/pages/yiwen_card.dart';

class YiWenPage extends StatefulWidget {
  YiWenPage({Key key}) : super(key: key);
  @override
  _YiWenPageState createState() => _YiWenPageState();
}

class _YiWenPageState extends State<YiWenPage> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    MainManager _mainManager = Provider.of<MainManager>(context);
    return Scaffold(
      appBar: AppBar(
        toolbarHeight: 50,
        elevation: 0,
        title: Text(
          "一文",
          style: TextStyle(
            color: Global.fontColor,
            fontSize: 17,
            fontFamily: 'fangzhengkai',
            fontWeight: FontWeight.w600,
          ),
        ),
        leading: IconButton(
          icon: Icon(
            _mainManager.isLike(_mainManager.yiwen)
                ? Icons.favorite
                : Icons.favorite_border,
            color: _mainManager.isLike(_mainManager.yiwen)
                ? Global.likeColor
                : Global.primaryColor,
          ),
          tooltip: '收藏',
          onPressed: () {
            _mainManager.like(_mainManager.yiwen);
          },
        ),
        actions: <Widget>[
          IconButton(
            icon: Icon(Icons.refresh),
            tooltip: '刷新',
            onPressed: () {
              _mainManager.getNewMeiRiYiWen();
            },
          )
        ],
      ),
      body: YiWenCard(yiwen: _mainManager.yiwen),
    );
  }
}
